<template>
	<view class="grid-item" @click.stop="handleToClick">
		<image :src="itemData.cover" mode="scaleToFill"></image>
		<text>{{ itemData.name }}</text>
	</view>
</template>
<script setup>
	const props = defineProps({
		itemData: {
			type: Object,
			default: () => {
				return {}
			}
		},
		itemIndex: {
			type: [Object, Number],
			default: () => {
				return -1
			}
		}
	})
	const emits = defineEmits(['itemClickIndex', 'itemClick'])

	const handleToClick = () => {
		emits('itemClick', props.itemData)
		emits('itemClickIndex', props.itemIndex)
	}
</script>
<style lang="scss" scoped>
	.grid-item {
		width: 177.5rpx;
		align-items: center;
		display: flex;
		flex-direction: column;

		&:active {
			opacity: 0.7;
		}

		image {
			margin-top: 24rpx;
			width: 89rpx;
			height: 89rpx;
			display: block;
		}

		text {
			margin-top: 17rpx;
			margin-bottom: 4rpx;
			font-size: 26rpx;
			color: #1D161F;
		}
	}
</style>